<?php
class Artice extends CI_Controller{
    function  __construct(){
        parent::__construct();
        $this->load->model('home_model');
        //http://localhost/phongkhamuytin/frontend/artice/index/tin-tuc.html
    }
    function index(){
        $alias4 = $this->uri->segment(1,0);
        $alias5 = $this->uri->segment(2,0);
        if($this->uri->segment(5,0)){
			$alias4 = $this->uri->segment(4,0);
			$alias5 = $this->uri->segment(5,0);
		}
        
        if($alias5 && strstr($alias5,'.html')){
            //echo 'sdkahfklsad';
            $aliasartice = substr($alias5,0,-5);
            $dataselect = $this->home_model->get_one('baiviet',array('alias'=>$aliasartice,'publish'=>1)); 
            $param = array('type'=>'artice','data'=>$dataselect);
        }else{
            $aliascata = substr($alias4,0,-5);
            $danhmucselect = $this->home_model->get_one('danhmuc',array('alias'=>$aliascata,'publish'=>1));
            if($danhmucselect->display != 0 || $danhmucselect->display == ''){
                $aliasartice = $aliascata;
                $dataselect = $this->home_model->get_one('baiviet',array('id'=>$danhmucselect->display,'publish'=>1));
                $param = array('type'=>'artice','data'=>$dataselect);
            }else{
                $dataselect = $danhmucselect;
                $param = array('type'=>'catalog','data'=>$dataselect);
            }
        }
        if(!empty($dataselect)){
                $data['title'] = $dataselect->title;
                $data['des'] = $dataselect->metades;
                $data['key'] = $dataselect->metakey;
                $data['content'] = $this->load->controller('mod_artice',$param,True);
        }else{
            $data['title'] = 'phòng khám uy tín';
            $data['des'] = 'phong kham uy tin';
            $data['key'] = 'phong kham uy tin';
            $data['content']= '<p>Trang web khong ton tai</p><p>Vui lòng truy cập trang chủ <a href="#" title="trang chủ">http://phongkhamuytin.vn</a></p>';
        }
            $data['topmenu'] = $this->load->controller('mod_topmenu/mod_topmenu',array(),true);
            $data['right']= $this->load->controller('mod_hotrotructuyen',array(),True).
                           $this->load->controller('mod_phongkhamvip',array(),True).//array('data'=>array('idchuyenkhoa'=>1,'iddiadiem',))
                           $this->load->controller('mod_quangcao',array(),True).
                           $this->load->controller('mod_tintuc_right',array(),True). 
                           $this->load->controller('mod_quangcao',array(),True); 
            $data['seach']=$this->load->controller('mod_slideshow',array(),True);
            $this->load->view('frontend/template',$data);
        
    }
}


?>